package com.fmy.security.service.defult;

import com.fmy.security.cache.Token;
import com.fmy.security.commons.enums.RespEnum;
import com.fmy.security.service.LoginHandler;
import org.springframework.security.core.AuthenticationException;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Mr.fmy
 * @version 1.0.0
 * @ClassName LoginHandlerDefult
 * @Description TODO
 * @createTime 2019/9/6 15:12
 */
public class LoginHandlerDefult implements LoginHandler<Map> {
    @Override
    public Map resultSuccess(Token token) {
        Map<String, Object> result = new HashMap<>(3);
        result.put("code", "200");
        result.put("data", token);
        result.put("msg", "ok");
        return result;
    }

    @Override
    public Map resultFail(AuthenticationException e) {
        Map<String, Object> result = new HashMap<>(3);
        result.put("code", RespEnum.LOGIN_FAIL.getCode());
        result.put("errMsg", RespEnum.LOGIN_FAIL.getDesc());
        return result;
    }

    @Override
    public void resultPrefix() {

    }
}
